﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DataInfo;
using KenLib.BusinessManager;
using System.Collections.Generic;
using System.Net.Mail;
using System.Net;
using KenLib.BusinessObject;

public partial class JOINT_frmJ_TraineeListSendEmail : System.Web.UI.Page
{
    面接情報Manager _面接情報Manager = new 面接情報Manager();
    面接詳細情報Manager _面接詳細情報Manager = new 面接詳細情報Manager();
    /// <summary>
    /// Coder: Thanh Dong
    /// Noi dung: Su kien form load
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        ((JOINT_MstPage_JOINT)this.Master).HideLiArea("frmJ_TraineeListSendEmail");
        ((JOINT_MstPage_JOINT)this.Master).changeTitle("確定候補者メール送信");
        txt_内容.Focus();
        if (Session["frmJ_TraineeListSelect"] == null)
        {
            Response.Redirect("frmJ_TraineeListSelect.aspx");
        }
        if (Session["frmJ_TraineeSearch_txt_面接日"] == null || Session["frmJ_TraineeSearch_txt_面接日"].ToString() == "" || Session["frmJ_TraineeSearch_ddl_組合選択_text"] == null || Session["frmJ_TraineeSearch_ddl_組合選択_text"].ToString() == "" || Session["frmJ_TraineeSearch_ddl_組合員企業選択_Text"] == null || Session["frmJ_TraineeSearch_ddl_組合員企業選択_Text"].ToString()=="")
        {
            Response.Redirect("frmJ_TraineeListSelect.aspx");
        }
        else
        {
            HiddenField_Date.Value = Session["frmJ_TraineeSearch_txt_面接日"].ToString();
            lbl_面接日.Text = Session["frmJ_TraineeSearch_txt_面接日"].ToString() + " " + Session["frmJ_TraineeSearch_ddl_組合選択_text"].ToString() + " " + Session["frmJ_TraineeSearch_ddl_組合員企業選択_Text"].ToString();
            DataTable dt = ConvertDataTableToDataTable();
            if (dt.Rows.Count > 0)
            {
                grv.DataSource = dt;
                grv.DataBind();
            }
            else
            {
                string strHeader = "氏名,性別,年齢,最終学歴";
                ShowGridViewNotClassEmpty(grv, strHeader, "データがありません。");
            }
        }
        
        RFV_Content.ErrorMessage = GetError("ER00001");
        RFV_ddl_来社時間時.ErrorMessage = GetError("ER00007");
        RFV_ddl_来社時間分.ErrorMessage = GetError("ER00007");
        RFV_来社日.ErrorMessage = GetError("ER00007");
        CV_来社日1.ErrorMessage = GetError("ER00005");
        RFV_txt_場所.ErrorMessage = GetError("ER00001");
        RFV_txt_持参物.ErrorMessage = GetError("ER00001");
        RFV_txt_問い合わせ先.ErrorMessage = GetError("ER00001");
        CV_来社日.ErrorMessage = GetError("ER00005");

    }

    protected void btnメール送信_Click(object sender, EventArgs e)
    {

        if (Session["frmJ_TraineeSearch_Mode"].ToString() == "insert")
        {
            面接情報 _面接情報 = new 面接情報();
            _面接情報.面接日 = Convert.ToDateTime(Session["frmJ_TraineeSearch_txt_面接日"]);
            int 団体ID = Convert.ToInt32(Session["frmJ_TraineeSearch_ddl_組合選択"]);
            int 企業ID = Convert.ToInt32(Session["frmJ_TraineeSearch_ddl_組合員企業選択"]);
            DataTable dt = ConvertDataTableToDataTable();
            DataTable dt2 = (DataTable)Session["frmJ_TraineeListSelect"];
            List<List<string>> listMail = ConvertListSendEmail(dt2);
            面接情報 _面接情報1 = Get面接情報();
            if (_面接情報Manager.frmJ_CandidateSendEmail_Insert_Transaction(_面接情報, 団体ID, 企業ID, dt, dt2, _面接情報1) == 0)
            {
                if (SendAllMail(RegisterTemplate(), listMail))
                 {
                     Session.Remove("frmJ_TraineeListSelect");
                     Session.Remove("frmJ_TraineeSearch_Search");
                     Session.Remove("frmJ_TraineeSearch_ddl_組合選択");
                     Session.Remove("frmJ_TraineeSearch_ddl_組合員企業選択");
                     Session.Remove("frmJ_TraineeSearch_txt_面接日");
                     Session.Remove("frmJ_TraineeSearch_flag");
                     Session.Remove("frmJ_TraineeListSelectCheck_ID_面接情報");
                     Session.Remove("frmJ_TraineeSearch_ddl_組合員企業選択_Text");
                     Session.Remove("frmJ_TraineeListSelect_flagindex");
                     Response.Redirect("frmJ_TraineeManager.aspx");
                 }
                 else
                 {
                     ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('メールが送り出来ません');</script>");
                     Response.Redirect("frmJ_TraineeManager.aspx");
                 }
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('データベースに接続ができません');</script>");
                Response.Redirect("frmJ_TraineeManager.aspx");
            }
            //面接情報 _面接情報 = new 面接情報();
            //_面接情報.面接日 = Convert.ToDateTime(Session["frmJ_TraineeSearch_txt_面接日"]);
            ////Insert buoc 1
            //int ID_out;
            //if (frmJ_TraineeListSelectCheck_Insert_面接情報(_面接情報, out ID_out) == 1)
            //{
            //    //Thoa dieu kien insert buoc 2
            //    int ID = ID_out;
            //    Session["frmJ_TraineeListSelectCheck_ID_面接情報"] = ID_out;
            //    int 団体ID = Convert.ToInt32(Session["frmJ_TraineeSearch_ddl_組合選択"]);
            //    int 企業ID = Convert.ToInt32(Session["frmJ_TraineeSearch_ddl_組合員企業選択"]);
            //    DataTable dt = ConvertDataTableToDataTable();
            //    for (int i = 0; i < dt.Rows.Count; i++)
            //    {
            //        int 応募情報ID = Convert.ToInt32(dt.Rows[i]["ID"]);
            //        string 面接番号 = str面接番号(i + 1);
            //        面接詳細情報 _面接詳細情報 = get面接詳細情報(ID, 団体ID, 企業ID, 応募情報ID, 面接番号);
            //        if (frmJ_TraineeListSelectCheck_Insert_面接詳細情報(_面接詳細情報) != 1)
            //        {
            //            ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('データベースに接続ができません');</script>");
            //            return;
            //        }
            //    }
            //    DataTable dt1 = (DataTable)Session["frmJ_TraineeListSelect"];
            //    List<List<string>> listmail = ConvertListSendEmail(dt1);

            //    面接情報 _面接情報1 = Get面接情報();
            //    if (_面接情報Manager.frmJ_CandidateSendEmail_Update面接情報(_面接情報1) == 1)
            //    {
            //        if (SendAllMail(RegisterTemplate(), listmail))
            //        {
            //            Session.Remove("frmJ_TraineeListSelect");
            //            Session.Remove("frmJ_TraineeSearch_Search");
            //            Session.Remove("frmJ_TraineeSearch_ddl_組合選択");
            //            Session.Remove("frmJ_TraineeSearch_ddl_組合員企業選択");
            //            Session.Remove("frmJ_TraineeSearch_txt_面接日");
            //            Session.Remove("frmJ_TraineeSearch_flag");
            //            Session.Remove("frmJ_TraineeListSelectCheck_ID_面接情報");
            //            Session.Remove("frmJ_TraineeSearch_ddl_組合員企業選択_Text");
            //            Session.Remove("frmJ_TraineeListSelect_flagindex");
            //            Response.Redirect("frmJ_TraineeManager.aspx");
            //        }
            //        else
            //        {
            //            ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('メールが送り出来ません');</script>");
            //            Response.Redirect("frmJ_TraineeManager.aspx");
            //        }
            //    }
            //    else
            //    {
            //        ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('データを更新できません。');</script>");
            //        Response.Redirect("frmJ_TraineeManager.aspx");

            //    }
            //}
            //else
            //{
            //    ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('データベースに接続ができません');</script>");
            //    return;
            //}
        }
        else if (Session["frmJ_TraineeSearch_Mode"].ToString() == "update")
        {
            DateTime 面接日 = Convert.ToDateTime(Session["frmJ_TraineeSearch_txt_面接日"]);
            int 団体ID = Convert.ToInt32(Session["frmJ_TraineeSearch_ddl_組合選択"]);
            int 企業ID = Convert.ToInt32(Session["frmJ_TraineeSearch_ddl_組合員企業選択"]);
            DataTable dt = frmJ_CandidateSendEmail_GetByID(面接日, 団体ID, 企業ID);
            DataTable dt1 = ConvertDataTableToDataTable();
            DataTable dt2 = (DataTable)Session["frmJ_TraineeListSelect"];
            List<List<string>> listMail = ConvertListSendEmail(dt2);
            面接情報 _面接情報1 = Get面接情報();
            if (_面接情報Manager.frmJ_CandidateSendEmail_Update_Transaction(面接日, 団体ID, 企業ID, dt, dt1, dt2, _面接情報1) == 0)
            {
                if (SendAllMail(RegisterTemplate(), listMail))
                 {
                     Session.Remove("frmJ_TraineeListSelect");
                     Session.Remove("frmJ_TraineeSearch_Search");
                     Session.Remove("frmJ_TraineeSearch_ddl_組合選択");
                     Session.Remove("frmJ_TraineeSearch_ddl_組合員企業選択");
                     Session.Remove("frmJ_TraineeSearch_txt_面接日");
                     Session.Remove("frmJ_TraineeSearch_flag");
                     Session.Remove("frmJ_TraineeListSelectCheck_ID_面接情報");
                     Session.Remove("frmJ_TraineeSearch_ddl_組合員企業選択_Text");
                     Response.Redirect("frmJ_TraineeManager.aspx");
                 }
                 else
                 {
                     ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('メールが送り出来ません');</script>");
                     Response.Redirect("frmJ_TraineeManager.aspx");
                 }
            }
            //DateTime 面接日 =  Convert.ToDateTime(Session["frmJ_TraineeSearch_txt_面接日"]);
            //int 団体ID = Convert.ToInt32(Session["frmJ_TraineeSearch_ddl_組合選択"]);
            //int 企業ID = Convert.ToInt32(Session["frmJ_TraineeSearch_ddl_組合員企業選択"]);
            //DataTable dt = frmJ_CandidateSendEmail_GetByID(面接日, 団体ID, 企業ID);
            //if (dt.Rows.Count > 0)
            //{
            //    int ID = Convert.ToInt32(dt.Rows[0]["ID"]);
            //    Session["frmJ_CandidateSendEmail_ID_面接情報"] = ID;
            //    if (frmJ_CandidateSendEmail_Delete_面接詳細情報(ID) == 1)
            //    {
            //        DataTable dt1 = ConvertDataTableToDataTable();
            //        for (int i = 0; i < dt1.Rows.Count; i++)
            //        {
            //            int 応募情報ID = Convert.ToInt32(dt1.Rows[i]["ID"]);
            //            string 面接番号 = str面接番号(i + 1);
            //            面接詳細情報 _面接詳細情報 = get面接詳細情報(ID, 団体ID, 企業ID, 応募情報ID, 面接番号);
            //            if (frmJ_TraineeListSelectCheck_Insert_面接詳細情報(_面接詳細情報) != 1)
            //            {
            //                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('データベースに接続ができません');</script>");
            //                return;
            //            }
            //        }
            //        DataTable dt2 = (DataTable)Session["frmJ_TraineeListSelect"];
            //        List<List<string>> listmail = ConvertListSendEmail(dt2);

            //        面接情報 _面接情報1 = Get面接情報();
            //        if (_面接情報Manager.frmJ_CandidateSendEmail_Update面接情報(_面接情報1) == 1)
            //        {
            //            if (SendAllMail(RegisterTemplate(), listmail))
            //            {
            //                Session.Remove("frmJ_TraineeListSelect");
            //                Session.Remove("frmJ_TraineeSearch_Search");
            //                Session.Remove("frmJ_TraineeSearch_ddl_組合選択");
            //                Session.Remove("frmJ_TraineeSearch_ddl_組合員企業選択");
            //                Session.Remove("frmJ_TraineeSearch_txt_面接日");
            //                Session.Remove("frmJ_TraineeSearch_flag");
            //                Session.Remove("frmJ_TraineeListSelectCheck_ID_面接情報");
            //                Session.Remove("frmJ_TraineeSearch_ddl_組合員企業選択_Text");
            //                Response.Redirect("frmJ_TraineeManager.aspx");
            //            }
            //            else
            //            {
            //                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('メールが送り出来ません');</script>");
            //                Response.Redirect("frmJ_TraineeManager.aspx");
            //            }
            //        }
            //    }
            //}
            
        }
        else
        {
            Response.Redirect("frmJ_TraineeSearch.aspx");
        }
        
        
        
        
        
        
      
        
        
        //if (SendAllMail(RegisterTemplate(), listmail))
        //{
        //    //Update table 面接情報
        //    面接情報 _面接情報 = Get面接情報();
        //    if (_面接情報Manager.frmJ_CandidateSendEmail_Update面接情報(_面接情報) == 1)
        //    {
        //        Session.Remove("frmJ_TraineeListSelect");
        //        Session.Remove("frmJ_TraineeSearch_Search");
        //        Session.Remove("frmJ_TraineeSearch_ddl_組合選択");
        //        Session.Remove("frmJ_TraineeSearch_ddl_組合員企業選択");
        //        Session.Remove("frmJ_TraineeSearch_txt_面接日");
        //        Session.Remove("frmJ_TraineeSearch_flag");
        //        Session.Remove("frmJ_TraineeListSelectCheck_ID_面接情報");
        //        Session.Remove("frmJ_TraineeSearch_ddl_組合員企業選択_Text");
        //        Response.Redirect("frmJ_TraineeManager.aspx");
        //    }
            
        //}
        //else
        //{
        //    ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('メールが送り出来ません');</script>");
        //}
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Noi dung: Lay ma loi dua vao id
    /// </summary>
    /// <param name="errorid"></param>
    /// <returns></returns>
    public String GetError(string errorid)
    {
        string error = "";
        Error er = new Error();
        er.ErrorID = errorid;
        ErrorManager frm_error = new ErrorManager();
        DataTable dt = frm_error.getError(er);
        if (dt.Rows.Count > 0)
        {
            error = dt.Rows[0][2].ToString();
        }
        return error;
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Noi dung: Chuyen tu datatable sang List
    /// </summary>
    /// <param name="dt"></param>
    /// <returns></returns>
    public List<List<string>> ConvertListSendEmail(DataTable dt)
    {
        List<List<string>> listEmail = new List<List<string>>();
       
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            List<string> list = new List<string>();
            list.Add(dt.Rows[i]["氏名"].ToString());
            list.Add(dt.Rows[i]["Email"].ToString());
            listEmail.Add(list);
        }
       
        return listEmail;
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Noi dung: Gui mail
    /// </summary>
    /// <param name="mail"></param>
    /// <param name="MailTo"></param>
    /// <param name="str_社員名"></param>
    /// <returns></returns>
    public bool sendMail(MailMessage mail, string MailTo, string str_社員名)
    {
        
        try
        {
            mail.Priority = MailPriority.Normal;
            mail.BodyEncoding = System.Text.Encoding.UTF8;
            mail.From = new MailAddress("contact@xanhbiec.com", "Xanh Biec");
            SmtpClient smtpclient = new SmtpClient();
            smtpclient.Host = "smtp.xanhbiec.com";
            smtpclient.Credentials = new NetworkCredential("contact@xanhbiec.com", "xanhbiec");
            mail.Subject = "Xin Chào " + str_社員名;
            mail.To.Add(MailTo);
            mail.IsBodyHtml = true;
            smtpclient.Send(mail);
            mail.To.Clear();
            return true;
        }
        catch( Exception ex)
        {
            return false;
        }
       
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Noi dung: Gui cung luc nhieu email
    /// </summary>
    /// <param name="mail"></param>
    /// <param name="listSendMail"></param>
    /// <returns></returns>
    public bool SendAllMail(MailMessage mail, List<List<string>> listSendMail)
    {
        for (int i = 0; i < listSendMail.Count; i++)
        { 
            string strMailTo =listSendMail[i][1].ToString();
            string str_社員名 = listSendMail[i][0].ToString();
            if (sendMail(mail, strMailTo, str_社員名) == false)
            {
                return false;
            }
        }
        return true;
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Noi dung: Template mail
    /// </summary>
    /// <returns></returns>
    public MailMessage RegisterTemplate()
    {
        string strContent = ConvertHTMLtoText(txt_内容.Text);
        string str_来社日 = ConvertDate(txt_来社日.Text);
        string str_ddl_来社時間時 = ddl_来社時間時.SelectedValue.ToString();
        string str_ddl_来社時間分 = ddl_来社時間分.SelectedValue.ToString();
        string str_txt_場所 = ConvertHTMLtoText(txt_場所.Text);
        string str_txt_持参物 = ConvertHTMLtoText(txt_持参物.Text);
        string str_txt_問い合わせ先 = ConvertHTMLtoText(txt_問い合わせ先.Text);
        MailMessage mail = new MailMessage();
        mail.BodyEncoding = System.Text.Encoding.UTF8;
        //mail.Subject = "Xin chào";// + ;
        string body = "";
        body += "<body>";
        body += strContent;
        body += "<br/><br/>";
        body += "Thời gian: ";
        body += str_来社日;
        body += "            ";
        body += "Vào lúc: ";
        body += str_ddl_来社時間時;
        body += " giờ - ";
        body += str_ddl_来社時間分;
        body += " phút";
        body += "<br/>";
        body += "Địa điểm: ";
        body += str_txt_場所;
        body += "<br/>";
        body += "Các tài liệu cần mang theo: ";
        body += str_txt_持参物;
        body += "<br/>";
        body += "Địa chỉ nơi hồi đáp: ";
        body += str_txt_問い合わせ先;
        body += "<br/>";
        body += Session["frmJ_TraineeSearch_ddl_組合員企業選択_Text"].ToString();
        body += "</body>";
        mail.Body = body;
        return mail;
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Noi dung: Chuyen ky html sang text
    /// </summary>
    /// <param name="temp"></param>
    /// <returns></returns>
    public string ConvertHTMLtoText(string temp)
    {
        temp = temp.Replace("<", "&lt;");
        temp = temp.Replace(">", "&gt;");
        temp = temp.Replace(Convert.ToString((char)13), "<br/>");
        return temp;
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Noi dung: Chuyen doi kieu chuoi sang ngay thang
    /// </summary>
    /// <param name="str"></param>
    /// <returns></returns>
    public string ConvertDate(string str)// ham convert nagy thang nam.
    {
        if (str == "")
        {
            return str = "";
        }
        else
        {
            string date = str;
            DateTime d1 = DateTime.Parse(date);
            d1.Year.ToString();
            return date = d1.ToString("yyyy/MM/dd");
        }
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Noi dung: Cap nhu du lieu cho table 面接情報
    /// </summary>
    /// <param name="_面接情報"></param>
    /// <returns></returns>
    public int frmJ_CandidateSendEmail_Update面接情報(面接情報 _面接情報)
    {
        if (_面接情報Manager.frmJ_CandidateSendEmail_Update面接情報(_面接情報) == 1)
        {
            return 1;
        }
        return 0;
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Noi dung: Lay doi tuong kieu 面接情報
    /// </summary>
    /// <returns></returns>
    public 面接情報 Get面接情報()
    {
        面接情報 _面接情報 = new 面接情報();

        //ID
        //Session["frmJ_TraineeListSelectCheck_ID_面接情報"] = ID_out;
        
        if (Session["frmJ_TraineeSearch_Mode"].ToString() == "update")
        {
            _面接情報.ID = Convert.ToInt32(Session["frmJ_CandidateSendEmail_ID_面接情報"]);
        }
        else
        {
            _面接情報.ID = Convert.ToInt32(Session["frmJ_TraineeListSelectCheck_ID_面接情報"]);
        }
        //内容
        _面接情報.内容 = ConvertHTMLtoText(txt_内容.Text);

        //来社日
        _面接情報.来社日 = Convert.ToDateTime(txt_来社日.Text);

        //来社時期
        _面接情報.来社時期 = Convert.ToString(ddl_来社時間時.SelectedValue) + Convert.ToString(ddl_来社時間分.SelectedValue);

        //場所
        _面接情報.場所 = ConvertHTMLtoText(txt_場所.Text);

        //持参物
        _面接情報.持参物 = ConvertHTMLtoText(txt_持参物.Text);

        //問い合わせ先
        _面接情報.問い合わせ先 = ConvertHTMLtoText(txt_問い合わせ先.Text);

        return _面接情報;
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Function: Check insert data in table 面接情報 true or false
    /// </summary>
    /// <param name="_面接情報"></param>
    /// <param name="ID"></param>
    /// <returns></returns>
    public int frmJ_TraineeListSelectCheck_Insert_面接情報(面接情報 _面接情報, out int ID)
    {
        if (_面接情報Manager.frmJ_TraineeListSelectCheck_Insert_面接情報(_面接情報, out ID) != -1)
        {
            return 1;
        }
        return 0;
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Function: Convert List to Datatable
    /// </summary>
    /// <returns></returns>
    public DataTable ConvertDataTableToDataTable()
    {
        DataTable dt = new DataTable();
        dt = (DataTable)Session["frmJ_TraineeListSelect"];
        return dt;
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Function: Add 0 first string. Ex: 01, 02....
    /// </summary>
    /// <param name="temp"></param>
    /// <returns></returns>
    public string str面接番号(int temp)
    {
        string kq = "";
        if (temp < 10)
        {
            kq = "0" + Convert.ToString(temp);
        }
        else
        {
            kq = Convert.ToString(temp);
        }
        return kq;
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Function: Get object 面接詳細情報
    /// </summary>
    /// <param name="ID"></param>
    /// <param name="団体ID"></param>
    /// <param name="企業ID"></param>
    /// <param name="応募情報ID"></param>
    /// <param name="面接番号"></param>
    /// <returns></returns>
    public 面接詳細情報 get面接詳細情報(int ID, int 団体ID, int 企業ID, int 応募情報ID, string 面接番号)
    {
        面接詳細情報 _面接詳細情報 = new 面接詳細情報();
        _面接詳細情報.ID = ID;
        _面接詳細情報.団体ID = 団体ID;
        _面接詳細情報.企業ID = 企業ID;
        _面接詳細情報.応募情報ID = 応募情報ID;
        _面接詳細情報.面接番号 = 面接番号;
        return _面接詳細情報;
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Function: Check insert data in table 面接詳細情報 true or false
    /// </summary>
    /// <param name="_面接詳細情報"></param>
    /// <returns></returns>
    public int frmJ_TraineeListSelectCheck_Insert_面接詳細情報(面接詳細情報 _面接詳細情報)
    {
        if (_面接詳細情報Manager.frmJ_TraineeListSelectCheck_Insert_面接詳細情報(_面接詳細情報) == 1)
        {
            return 1;
        }
        return 0;
    }

    
    /// <summary>
    /// Coder: Thanh Dong
    /// Function: Get ID from table 面接情報
    /// </summary>
    /// <param name="面接日"></param>
    /// <param name="団体ID"></param>
    /// <param name="企業ID"></param>
    /// <returns></returns>
    public DataTable frmJ_CandidateSendEmail_GetByID(DateTime 面接日, int 団体ID, int 企業ID)
    {
        DataTable dt = new DataTable();
        dt = _面接情報Manager.frmJ_CandidateSendEmail_GetByID(面接日, 団体ID, 企業ID);
        return dt;
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Function: Delete table 面接詳細情報 where ID
    /// </summary>
    /// <param name="ID"></param>
    /// <returns></returns>
    public int frmJ_CandidateSendEmail_Delete_面接詳細情報(int ID)
    {
        if (_面接詳細情報Manager.frmJ_CandidateSendEmail_Delete_面接詳細情報(ID) >= 1)
            return 1;
        return 0;
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Noi dung: Hien thi gridview rong
    /// </summary>
    /// <param name="grv"></param>
    /// <param name="strTableHeader"></param>
    /// <param name="strEmpty"></param>
    public void ShowGridViewNotClassEmpty(GridView grv, string strTableHeader, string strEmpty)
    {
        DataTable dt = new DataTable();
        string[] arrColumnNames = strTableHeader.Split(',');
        foreach (string str in arrColumnNames)
        {
            dt.Columns.Add(str);
        }
        grv.ShowFooter = false;
        DataRow r = dt.NewRow();
        dt.Rows.InsertAt(r, 0);
        grv.DataSource = dt;
        grv.DataBind();
        grv.Rows[0].Cells.Clear();
        TableCell cell = new TableCell();
        cell.ColumnSpan = grv.Columns.Count + 1;
        cell.Text = strEmpty;
        grv.Rows[0].Cells.Add(cell);

    }

    protected void grv_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grv.PageIndex = e.NewPageIndex;
        DataTable dt = ConvertDataTableToDataTable();
        grv.DataSource = dt;
        grv.DataBind();
    }
}
